package cn.laixueit;

import javax.sound.midi.Soundbank;
import java.util.Arrays;

public class Demo3 {
    public static void main(String[] args) {
//        int[] arr = {1,2,3,4,8,7,5,3,4};
//        Arrays.sort(arr);// ctrl + 左键
//        System.out.println(Arrays.toString(arr));

        /*int[][] arrs = new int[3][5];
        arrs[0][0] = 2;
        arrs[0][1] = 22;
        arrs[0][2] = 32;
        arrs[0][3] = 25;
        arrs[0][4] = 21;
        arrs[1][0] = 12;
        arrs[1][1] = 32;
        arrs[1][2] = 2;
        arrs[1][3] = 235;
        arrs[1][4] = 321;*/
//        Arrays.sort(arrs); // 编译，运行
//        System.out.println(Arrays.toString(arrs));
        /*for (int i = 0; i < arrs.length; i++) {
            Arrays.sort(arrs[i]);
            System.out.println(Arrays.toString(arrs[i]));
        }*/

        /*String s[] = {"a","b","d","c"};
        Arrays.sort(s);
        System.out.println(Arrays.toString(s));*/


//        int[] arr = {1,2,3,5,4,6};
//        Arrays.fill(arr,19);/将数组中指定范围的值改变为你所指定的
//        Arrays.fill(arr,1,3,0);//包左不包右
//        System.out.println(Arrays.toString(arr));

//        int[] copyArr = Arrays.copyOf(arr, 3);
//        System.out.println(Arrays.toString(copyArr));

//        int[] b = arr;
//        System.out.println(Arrays.toString(b));
//        b[1] = 100;
//        System.out.println(Arrays.toString(b));// {1,100,3,5,4,6};
//        System.out.println(Arrays.toString(arr));//{1,2,3,5,4,6};


       /*
        int[] arr = {1,2,3,5,4,6};

        int[] arrCopy = Arrays.copyOf(arr, 6);

        System.out.println(Arrays.toString(arr));
        System.out.println(Arrays.toString(arrCopy));
        arrCopy[1] = 100;
        System.out.println(Arrays.toString(arrCopy));
        System.out.println(Arrays.toString(arr));
       */

       /* int[] arr = {1,2,3,5,4,6};
        Arrays.sort(arr);//{1,2,3,4,5,6}
        int index = Arrays.binarySearch(arr, 5);
        System.out.println(index);*/

        /*
        String[] names = new String[999];// {"张三","李四","王五",};
        names[0] ="张三";
        names[1] ="李四";
        names[2] ="王五";
        names[3] ="哈哈";
        for (int i = 0; i < names.length; i++) {
            if("哈哈".equals(names[i])){// nullpoint 空指针异常
                names[i] = null;
            }
            if(names[i] != null){
                System.out.print(names[i]+",");//"张三""李四""王五"null
            }
        }*/

        /*
        *
        * Arrays ：
        *   equals()：比较两个数组中值是否相等（顺序和内容都一致才相等）
        *   toString(): 输出数组中的所有元素值
        *   sort(): 升序排序数组
        *   copyOf():复制一个数组，返回一个新的数组
        *   fill(): 将数组中的元素修改为你指定的值
        *   binarySearch():搜索数组中你指定值的索引位置(必须是sort排序后的数组，否则返回结果未知)
        *  具体内容参考 ：api文档
        *
        *  之前自己写的排序方法：冒泡排序
        * */
    }
}
